<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改器材型号')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-mode-edit" th:object="${entityDeviceMode}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">器材类型：</label>
                <div class="col-sm-8">
                    <input name="typeName" th:field="*{typeName}"  class="form-control" type="text" required autocomplete="off">
                    <input name="typeId" class="form-control" type="hidden" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">器材型号：</label>
                <div class="col-sm-8">
                    <input name="modeName" th:field="*{modeName}"  class="form-control" type="text" required autocomplete="off">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">单位：</label>
                <div class="col-sm-8">
                    <select name="unit" class="form-control" th:field="*{unit}" th:with="type=${@dict.getType('sys_unit')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">顺序：</label>
                <div class="col-sm-8">
                    <input name="sequence" th:field="*{sequence}" class="form-control" type="number" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">状态：</label>
                <div class="col-sm-8">
                    <select class="form-control" name="valid" th:field="*{valid}" th:with="type=${@dict.getType('sys_valid')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var icon = "<i class='fa fa-times-circle'></i> ";
        var prefix = ctx + "system/mode";
        $("#form-mode-edit").validate({
            focusCleanup: true,
            rules: {
                typeId: "required",
                modeName: {
                    required: true,
                    remote: {
                        url: "/system/mode/checkModeName",     //后台处理程序
                        type: "post",               //数据发送方式
                        dataType: "json",           //接受数据格式
                        data: {                     //要传递的数据
                            modeName: function () {
                                return $("#modeName").val();
                            }, id: function () {
                                return $("#id").val();
                            }
                        }
                    }
                }
            },
            messages: {
                typeId: icon + "请选择器材类型",
                modeName: {
                    required: icon + "请输入器材型号名称",
                    remote: icon + "该器材型号名称已经存在"
                }
            }
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-mode-edit').serialize());
            }
        }
    </script>
</body>
</html>